package com.itheima.homework03;

import java.math.BigDecimal;
import java.math.RoundingMode;


public class BigDecimalTest {
    public static void main(String[] args) {
        double[] arr = {0.1,0.2,2.1,3.2,5.56,7.21};
        BigDecimal sum1 = BigDecimal.valueOf(0);
        for (int i = 0; i < arr.length; i++) {
            sum1=sum1.add(BigDecimal.valueOf(arr[i]));
        }
        BigDecimal aver = sum1.divide(BigDecimal.valueOf(arr.length),2, RoundingMode.HALF_UP);
        System.out.println(aver);
    }
}
